package com.nekonomics
package api.dto.response

import domain.auxiliary.UserView

import zio.json.*

case class UserProfileDto(
  id: Long, 
  email: String, 
  nickname: String, 
  avatarUrl: Option[String],
  role: String
) derives JsonCodec


object UserProfileDto {
  given JsonDecoder[UserProfileDto] = DeriveJsonDecoder.gen

  given JsonEncoder[UserProfileDto] = DeriveJsonEncoder.gen


  def fromUserView(user: UserView): UserProfileDto =
    UserProfileDto(
      id = user.id, 
      email = user.email, 
      nickname = user.nickname, 
      avatarUrl = user.avatarUrl,
      role = user.role.toString
    
    )


}